{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e037814a",
   "metadata": {},
   "source": [
    "### 上周学习内容\n",
    "* A.python的第一行代码\n",
    "* B.观察标准库\n",
    "\n",
    "#### 重要资源：\n",
    "> [PYTHON官网](https://python.org)\n",
    "\n",
    "> [blogs](https://cnblogs.com/xuzhichao)\n",
    "\n",
    "\n",
    "### 本周学习内容\n",
    "\n",
    "#### 1.python环境配置\n",
    "* A. [pycharm](https://www.jetbrains.com/pycharm/)\n",
    "> a.项目管理类的IDE\n",
    "> b.[github education pack](https://education.github.com/pack)可获得免费一年 专业版使用\n",
    "\n",
    "#### 2.项目1：奇数中选择指定时间\n",
    "#### 3.变量\n",
    "> 变量只能是字母、数字、下划线组合\n",
    "> 变量名开头不能是数字\n",
    "> 以下关键词不能声明为变量名\n",
    "[]\n",
    "\n",
    "#### 4. if else 条件判断\n",
    "> 二级层是执行过程即是else 行\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "21d6eb1e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Not an odd minute.\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "odds = [ 1,3,5,7,9,11,13,15,17,19,\n",
    "        21,23,25,27,29,31,33,35,37,39,\n",
    "        41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")\n",
    "\n",
    "\n",
    "from datetime import datetime\n",
    "odds = [ 1,3,5,7,9,11,13,15,17,19,\n",
    "        21,23,25,27,29,31,33,35,37,39,\n",
    "        41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "#range(5)决定了for循环的次数，即for循环过程中的执行次数\n",
    "\n",
    "for i in range (5):\n",
    "#由print（i）这件案例我们明白了，在循环过程中，变量名虽然没变，但值是动态变化的，也就以为着\n",
    "#所有的for循环中的变量值都在随着循环次数的改变而改变\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")\n",
    "\n",
    "wait_time = random.randint(1,5)\n",
    "time.sleep(wait_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "82368373",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "54"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.today().minute"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d4834821",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "guosiwen jianglaoban\n",
      "jianglaoban jianglaoban\n"
     ]
    }
   ],
   "source": [
    "name = \"guosiwen\"\n",
    "name2 = \"jianglaoban\"\n",
    "print(name,name2)\n",
    "\n",
    "name = \"jianglaoban\"\n",
    "print(name,name2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d7cafae2",
   "metadata": {},
   "source": [
    "## 变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9fad410a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "lihaha lihaha\n",
      "What is the value of name2 now?\n"
     ]
    }
   ],
   "source": [
    "name = \"lihaha\"\n",
    "\n",
    "name2 = name\n",
    "print(name,name2)\n",
    "\n",
    "name = \"lizhubo\"\n",
    "\n",
    "print(\"What is the value of name2 now?\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6753df61",
   "metadata": {},
   "source": [
    "## 从python基础库中找到 datetime 模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8874391d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2021, 11, 14, 17, 5, 18, 624318)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "datetime .today()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5ba5fa14",
   "metadata": {},
   "source": [
    "## 课本代码"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "263cae6a",
   "metadata": {},
   "source": [
    "### （项目一，从奇数中选择对应的时间节点）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "5da2b576",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "时间是奇数，时间在oods的数据中\n"
     ]
    }
   ],
   "source": [
    "odds =[1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "right_this_minute = datetime.today().minute\n",
    "if right_this_minute in odds:\n",
    "    print(\"时间是奇数，时间在oods的数据中\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")\n",
    "    \n",
    "## 时间指的是当前时间的分钟，分为奇数和偶数两种情况"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c3c9cac0",
   "metadata": {},
   "source": [
    "### for循环"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "4e1d3736",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "96b8cb56",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "import time "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "786227c4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Not an odd minute\n",
      "This minute seems a litte odd\n",
      "This minute seems a litte odd\n",
      "This minute seems a litte odd\n",
      "This minute seems a litte odd\n"
     ]
    }
   ],
   "source": [
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "for i in range(5):\n",
    "    right_this_minute = datetime.today().minute\n",
    "    if right_this_minute in odds:\n",
    "        print(\"This minute seems a litte odd\")\n",
    "    else:\n",
    "        print(\"Not an odd minute\")\n",
    "        wait_time = random.randint(1,60)\n",
    "        time.sleep(wait_time)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b800d31",
   "metadata": {},
   "source": [
    "### 啤酒歌谣"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "4b67e14e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles of beer on the wall.\n",
      "99 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "98 bottles of beer on the wall.\n",
      "98 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "97 bottles of beer on the wall.\n",
      "97 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "96 bottles of beer on the wall.\n",
      "96 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "95 bottles of beer on the wall.\n",
      "95 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "94 bottles of beer on the wall.\n",
      "94 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "93 bottles of beer on the wall.\n",
      "93 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "92 bottles of beer on the wall.\n",
      "92 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "91 bottles of beer on the wall.\n",
      "91 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "90 bottles of beer on the wall.\n",
      "90 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "89 bottles of beer on the wall.\n",
      "89 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "88 bottles of beer on the wall.\n",
      "88 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "87 bottles of beer on the wall.\n",
      "87 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "86 bottles of beer on the wall.\n",
      "86 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "85 bottles of beer on the wall.\n",
      "85 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "84 bottles of beer on the wall.\n",
      "84 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "83 bottles of beer on the wall.\n",
      "83 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "82 bottles of beer on the wall.\n",
      "82 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "81 bottles of beer on the wall.\n",
      "81 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "80 bottles of beer on the wall.\n",
      "80 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "79 bottles of beer on the wall.\n",
      "79 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "78 bottles of beer on the wall.\n",
      "78 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "77 bottles of beer on the wall.\n",
      "77 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "76 bottles of beer on the wall.\n",
      "76 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "75 bottles of beer on the wall.\n",
      "75 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "74 bottles of beer on the wall.\n",
      "74 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "73 bottles of beer on the wall.\n",
      "73 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "72 bottles of beer on the wall.\n",
      "72 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "71 bottles of beer on the wall.\n",
      "71 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "70 bottles of beer on the wall.\n",
      "70 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "69 bottles of beer on the wall.\n",
      "69 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "68 bottles of beer on the wall.\n",
      "68 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "67 bottles of beer on the wall.\n",
      "67 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "66 bottles of beer on the wall.\n",
      "66 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "65 bottles of beer on the wall.\n",
      "65 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "64 bottles of beer on the wall.\n",
      "64 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "63 bottles of beer on the wall.\n",
      "63 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "62 bottles of beer on the wall.\n",
      "62 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "61 bottles of beer on the wall.\n",
      "61 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "60 bottles of beer on the wall.\n",
      "60 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "59 bottles of beer on the wall.\n",
      "59 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "58 bottles of beer on the wall.\n",
      "58 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "57 bottles of beer on the wall.\n",
      "57 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "56 bottles of beer on the wall.\n",
      "56 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "55 bottles of beer on the wall.\n",
      "55 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "54 bottles of beer on the wall.\n",
      "54 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "53 bottles of beer on the wall.\n",
      "53 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "52 bottles of beer on the wall.\n",
      "52 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "51 bottles of beer on the wall.\n",
      "51 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "50 bottles of beer on the wall.\n",
      "50 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "49 bottles of beer on the wall.\n",
      "49 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "48 bottles of beer on the wall.\n",
      "48 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "47 bottles of beer on the wall.\n",
      "47 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "46 bottles of beer on the wall.\n",
      "46 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "45 bottles of beer on the wall.\n",
      "45 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "44 bottles of beer on the wall.\n",
      "44 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "43 bottles of beer on the wall.\n",
      "43 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "42 bottles of beer on the wall.\n",
      "42 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "41 bottles of beer on the wall.\n",
      "41 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "40 bottles of beer on the wall.\n",
      "40 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "39 bottles of beer on the wall.\n",
      "39 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "38 bottles of beer on the wall.\n",
      "38 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "37 bottles of beer on the wall.\n",
      "37 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "36 bottles of beer on the wall.\n",
      "36 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "35 bottles of beer on the wall.\n",
      "35 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "34 bottles of beer on the wall.\n",
      "34 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "33 bottles of beer on the wall.\n",
      "33 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "32 bottles of beer on the wall.\n",
      "32 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "31 bottles of beer on the wall.\n",
      "31 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "30 bottles of beer on the wall.\n",
      "30 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "29 bottles of beer on the wall.\n",
      "29 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "28 bottles of beer on the wall.\n",
      "28 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "27 bottles of beer on the wall.\n",
      "27 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "26 bottles of beer on the wall.\n",
      "26 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "25 bottles of beer on the wall.\n",
      "25 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "24 bottles of beer on the wall.\n",
      "24 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "23 bottles of beer on the wall.\n",
      "23 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "22 bottles of beer on the wall.\n",
      "22 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "21 bottles of beer on the wall.\n",
      "21 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "20 bottles of beer on the wall.\n",
      "20 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "19 bottles of beer on the wall.\n",
      "19 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "18 bottles of beer on the wall.\n",
      "18 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "17 bottles of beer on the wall.\n",
      "17 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "16 bottles of beer on the wall.\n",
      "16 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "15 bottles of beer on the wall.\n",
      "15 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "14 bottles of beer on the wall.\n",
      "14 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "13 bottles of beer on the wall.\n",
      "13 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "12 bottles of beer on the wall.\n",
      "12 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "11 bottles of beer on the wall.\n",
      "11 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "10 bottles of beer on the wall.\n",
      "10 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "9 bottles of beer on the wall.\n",
      "9 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "8 bottles of beer on the wall.\n",
      "8 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "7 bottles of beer on the wall.\n",
      "7 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "6 bottles of beer on the wall.\n",
      "6 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "5 bottles of beer on the wall.\n",
      "5 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "4 bottles of beer on the wall.\n",
      "4 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "3 bottles of beer on the wall.\n",
      "3 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "2 bottles of beer on the wall.\n",
      "2 bottles of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "1 bottle of beer on the wall.\n",
      "\n",
      "1 bottle of beer on the wall.\n",
      "1 bottle of beer.\n",
      "Take one down.\n",
      "pass it aroud.\n",
      "No more bottles of beer on the wall.\n"
     ]
    }
   ],
   "source": [
    "word = \"bottles\"\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"of beer on the wall.\")\n",
    "    print(beer_num,word,\"of beer.\")\n",
    "    print(\"Take one down.\")\n",
    "    print(\"pass it aroud.\")\n",
    "    if beer_num ==1:\n",
    "        print(\"No more bottles of beer on the wall.\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num ==1:\n",
    "            word = \"bottle\"\n",
    "            print(new_num,word,\"of beer on the wall.\")\n",
    "            print()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
